#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#define _WIN32_WINNT 0x0500
#define STRICT
#include <windows.h>
#include <ntsecapi.h>
#include <iostream>
using namespace std;

int wmain(int argc, const wchar_t** argv)
{
	argc--;
	argv++;

	const wchar_t* accountName = L"tester";

	LSA_OBJECT_ATTRIBUTES attributes;
	ZeroMemory(&attributes, sizeof(attributes));
	LSA_HANDLE policy;
	if(LsaOpenPolicy(NULL, &attributes, POLICY_LOOKUP_NAMES, &policy) == 0)
	{
		DWORD sidSize = 0, domainNameSize = 0;
		SID_NAME_USE nameUse;
		LookupAccountName(NULL, accountName, NULL, &sidSize, NULL, &domainNameSize, &nameUse);
		PSID sid = (PSID)new char[sidSize];
		wchar_t* domainName = new wchar_t[domainNameSize];
		if(LookupAccountName(NULL, accountName, &sid, &sidSize, domainName, &domainNameSize, &nameUse))
		{
//			LsaAddAccountRights(policy, &sid, 
		}
		delete [] (char*)sid;
		delete [] domainName;

		LsaClose(policy);
	}

	return 0;
}
